//	--------------------------------------------------------------------
//	Copyright(C) 2006,2007 Zhao Yukun. All rights reserved.
//	This file is a part of the Xeres system.
//	Xeres 2007
//	Contact : xeres.engine@gmail.com
//	$(reservedInfo)
//	$(reservedDeclaration)
//	--------------------------------------------------------------------
///	@file	<CLocalFile.h>
///	@path	~/src/database/xres/
///	@date	2007/11/21
///	@desc	Local file class.

#pragma once

#include "xeres.h"

#include "lib/system/file_op.h"

#include "database/store/IFile.h"

namespace xeres {

	/*!
		\class	CLocalFile
		\brief	Local file class.
	*/
	class CLocalFile : public IFile
	{
	public:

		/// \ctor
		CLocalFile( void );

		/// \dtor
		virtual ~CLocalFile( void );

		DECL_IOBJECT_CLASS( CLocalFile , IFile );

	public:

	//@ interface

		/*!
			\brief		Get file info.
		*/
		virtual bool GetInfo( DataInfo& datainfo );

		/*!
			\brief		Get file path.
		*/
		virtual WString GetPath( void );

		/*!
			\brief		Seek to file pos.
		*/
		virtual bool Seek( int64 pos , bool abs_seek );

		/*!
			\brief		Seek to end of file.
		*/
		virtual bool SeekEof( void );

		/*!
			\brief		Get current file pos.
		*/
		virtual uint64 Tell( void );

		/*!
			\brief		Read data from file.
		*/
		virtual size_t Read( void * data , size_t size );

		/*!
			\brief		Write data to file.
		*/
		virtual size_t Write( const void * data , size_t size );

	//@ local

		/*!
			\brief		Get internal file op struct.
		*/
		FileOp& op( void ) { return m_file; }

	private:

	//@ data

		// file op
		FileOp		m_file;
	};

} // namespace xeres
